package site.yunnong.atvris.common.utils;

import org.apache.commons.lang3.StringUtils;
import site.yunnong.atvris.common.constant.CommonConstant;

/**
 * @author zjh
 * @date 2021/7/11 16:35
 */
public class SqlUtils {

    /**
     * 生成排序段
     * @param sortBy
     * @param sortRule
     * @return
     */
    public static String generateOrderByClause(String sortBy, String sortRule) {
        StringBuffer orderByClause =new StringBuffer()
                .append(sortBy)
                .append(CommonConstant.BLANK_SPACE)
                .append(StringUtils.isEmpty(sortRule) ? CommonConstant.ASC_SORT : sortRule);
        return orderByClause.toString();
    }
}
